package com.example.myapplication.utils

import com.google.gson.Gson
import com.google.gson.JsonObject
import com.google.gson.JsonParser
import com.google.gson.reflect.TypeToken

object JsonUtils {
    fun toArrList(jsonString: String): ArrayList<Map<String, Any>> {
        val type = object : TypeToken<ArrayList<Map<String, Any>>>() {}.type
        return Gson().fromJson(jsonString, type)
    }

    fun toObject(jsonString: String): JsonObject {
        return JsonParser.parseString(jsonString) as JsonObject
    }

    fun getString(jsonObject: JsonObject, key: String): String {
        return jsonObject.get(key).toString().replace("\"", "")
    }
}